// pages/order-detail/order-detail.js
import { URL, SER_KEY } from "../../config.js"
import { POST, GET } from "../../utils/request.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderId:null,
    details:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    options && options.id ? this.setData({ orderId: options.id }, () => this.getList()):''
    let shopMsg = JSON.parse(wx.getStorageSync('shopData'))
    console.log(shopMsg)
    this.setData({
      shopMsg: shopMsg
    })
  },
  getList() {
    let that = this;
    let url = URL.HTTP_BASE_INTRANET + SER_KEY.SER_KEY20;
    let data = {
      appid: getApp().globalData.appId,
      sessionId: wx.getStorageSync('session_id'),
      shopId: that.data.shopMsg.id,
      id: that.data.orderId
    };
    GET(url, data, (ret) => {
      if (ret.statusCode == 200) {
        console.log(ret)
        this.setData({
          details: ret.data.order
        })
      } else {
        wx.showToast({
          title: '数据走丢啦，请稍后再试',
          icon: 'none'
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})